package v1

import (
	"context"
	"vite-tsc-gin/api"
	"vite-tsc-gin/internal/apiserver/store"
)

/*
关于业务的所有处理函数
*/
type UserSrv interface {
	Create(ctx context.Context, user *api.User) error
	Update(ctx context.Context, user *api.User) error
	// Delete(ctx context.Context, username string, opts metav1.DeleteOptions) error
	// DeleteCollection(ctx context.Context, usernames []string, opts metav1.DeleteOptions) error
	Get(ctx context.Context, username string) (*api.User, error)
	// List(ctx context.Context, opts metav1.ListOptions) (*v1.UserList, error)
	// ListWithBadPerformance(ctx context.Context, opts metav1.ListOptions) (*v1.UserList, error)
	// ChangePassword(ctx context.Context, user *v1.User) error
}
type userService struct {
	store store.Factory
}

func newUsers(srv *service) *userService {
	return &userService{store: srv.store}
}

func (u *userService) Create(ctx context.Context, user *api.User) error {
	return u.store.Users().Create(ctx, user)
}
func (u *userService) Update(ctx context.Context, user *api.User) error {
	return u.store.Users().Update(ctx, user)
}
func (u *userService) Get(ctx context.Context, username string) (*api.User, error) {
	return u.store.Users().Get(ctx, username)
}
